<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JS-对象-DOM-案例</title>
</head>

<body>
    <img id="h1" src="./图片素材/off.gif">  <br><br>

    <div class="cls">传智教育</div>   <br>
    <div class="cls">黑马程序员</div>  <br>

    <input type="checkbox" name="hobby"> 电影
    <input type="checkbox" name="hobby"> 旅游
    <input type="checkbox" name="hobby"> 游戏
    <br><br>
    <input onclick="fun1()" type="submit" value="点亮灯泡">
    <br><br>
    <input onclick="fun2()" type="submit" value="加文字">
    <br><br>
    <input onclick="fun3()" type="submit" value="勾复选框">
</body>

<script>
    //点亮灯泡 : src 属性值
    function fun1(){
        document.getElementById('h1').src="./图片素材/on.gif";
    }
    //加上very good : 将所有div标签的内容后面加上: very good (红色字体) -- <font color='red'></font>
    function fun2(){
        var divName = document.getElementsByClassName('cls');
        for(let i=0;i<divName.length;i++){
            divName[i].innerHTML = divName[i].innerHTML + "<span style='color:red'>&nbsp;very good</span>";
        }
    }
    //使所有的复选框呈现选中状态
    function fun3(){
        var divName = document.getElementsByName('hobby');
        for(let i=0;i<divName.length;i++){
            divName[i].checked = true;
        }
    }
</script>
</html>